package rmi;

import java.rmi.*;
import bean.Cliente;

public class ClienteRMI {

	private static ClienteRMI instancia;
	private InterfazRemota iRemota;
	
	public ClienteRMI () {		
	}
	
	public static ClienteRMI getInstance()
	{
		if (instancia == null)
			instancia = new ClienteRMI();
		return instancia;	
	}

	public boolean getStub() {
    	System.setProperty("java.security.policy", "java.policy");
    	boolean ok = false;
    	try {
    		System.setSecurityManager(new RMISecurityManager());
			iRemota = (InterfazRemota)Naming.lookup ("//localhost/ObjetoRemoto");
			System.out.println("Conectado con servicio remoto.");
			ok = true;
		} catch (Exception e) {
			System.out.println("No se pudo conectar con servicio remoto." + "\n" + e.getMessage());
		}
		return ok;
    }

	public InterfazRemota getIRemota() {
		return iRemota;
	}
	
	
}

